home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Moscow ML 1.31 / source code / mosml / src / test / test3.sml < prev    next >
Encoding:
Text File  |  1996-07-03  |  340 b   |  17 lines  |  [TEXT/R*ch]

  1. datatype 'a Tree =
  2.     Lf
  3.   | Br of 'a * 'a Tree * 'a Tree
  4. ;
  5.  
  6. val t1 = Br(2, Br(1, Lf, Lf), Br(3, Lf, Lf));
  7.  
  8. fun foldTree f u Lf = u
  9.   | foldTree f u (Br(a, left, right)) =
  10.       f a (foldTree f u left) (foldTree f u right)
  11. ;
  12.  
  13. fun revBranch a left right = Br(a, right, left);
  14.  
  15. val reflect = foldTree revBranch Lf;
  16.  
  17. val refl_t1 = reflect t1;